package de.matusystems

import grails.converters.JSON
import groovy.json.JsonBuilder

class SendController {
	
	def emailService

    def index() {
		
		log.debug("send controller called")
		
		def mailTo = params['to']
		def mailSubject = params['subject']
		def mailBody = params['message']
		
		def success = emailService.send(mailTo, mailSubject, mailBody)
		
		def builder = new JsonBuilder()
		
		def json = builder.antwort{
			send success
			to mailTo
			subject mailSubject
			body mailBody
		}
		
		render json as JSON
	}
}
